glimpse(lodesresidents_blkgp)
## Rows: 43
## Columns: 15
## $ blkgroup <dbl> 510010901001, 510010901002, 510010901003, 5100109…
## $ medc_allblk <dbl> 45.87512, 45.43606, 37.65439, 41.07406, 43.54075,…
## $ medc_workinRegionblk <dbl> 8.998906, 7.036666, 8.178206, 8.454102, 8.173306,…
## $ medc_within40blk <dbl> 8.370839, 6.173518, 7.641535, 6.434638, 8.382186,…
## $ medc_25_employeesblk <dbl> 13.525101, 18.134192, 21.045550, 11.301578, 19.61…
## $ commutersInBlgr <int> 429, 370, 288, 261, 263, 972, 657, 276, 285, 339,…
## $ commuterinRegionblk <int> 298, 250, 205, 180, 168, 647, 432, 156, 167, 202,…
## $ commuterw40blk <int> 291, 248, 202, 176, 170, 643, 437, 163, 173, 210,…
## $ commuter25blk <int> 323, 286, 234, 202, 201, 746, 492, 177, 196, 233,…
## $ avgc_allblk <dbl> 45.60011, 44.03670, 39.39414, 42.69355, 45.55925,…
## $ avgc_workinRegionblk <dbl> 9.695082, 7.122045, 8.307257, 8.208582, 8.390502,…
## $ avgc_within40blk <dbl> 8.820367, 6.808916, 7.761259, 7.403881, 8.730307,…
## $ avgc_25_employeesblk <dbl> 16.67561, 18.71414, 18.45512, 19.53141, 22.44348,…
## $ county <int> 51001, 51001, 51001, 51001, 51001, 51001, 51001, …
## $ GEOID <chr> "510010901001", "510010901002", "510010901003", "…
metaresidents %>%
filter(su_blkgp == 1) %>%
select(varname, about) %>% as.list()
## $varname
## [1] "blkgroup" "county" "avgc_allblk"
## [4] "medc_allblk" "commutersInBlgr" "avgc_within40blk"
## [7] "medc_within40blk" "commuterw40blk" "avgc_25_employeesblk"
## [10] "medc_25_employeesblk" "commuter25blk" "avgc_workinRegionblk"
## [13] "medc_workinRegionblk" "commuterinRegionblk"
##
## $about
## [1] "12-digit census block group code"
## [2] "5-digit county code"
## [3] "Average \"as the crow flies\" commuting distance for all residents of the census block group"
## [4] "Median \"as the crow flies\" commuting distance for all residents of the census block group"
## [5] "The number of residents in each census block group who are represented in the data"
## [6] "Average \"as the crow flies\" commuting distance for residents of the census block group who work within 40 miles"
## [7] "Median \"as the crow flies\" commuting distance for residents of the census block group who work within 40 miles"
## [8] "The number of residents in the census block group who work within 40 miles of home"
## [9] "Average \"as the crow flies\" commuting distance for residents of the census block group who commute to a census tract that employs at least 25 residents from the region of interest"
## [10] "Median \"as the crow flies\" commuting distance for residents of the census block group who commute to a census tract that employs at least 25 residents of the region of interest"
## [11] "The number of residents in the census block group who commute to a census tract that employs at least 25 residents of the region of interest"
## [12] "Average \"as the crow flies\" commuting distance for residents of the census block group who work in the same region as where they live"
## [13] "Median \"as the crow flies\" commuting distance for residents of the census block group who work in the same region as where they live"
## [14] "The number of residents in the census block group who commute to work within the region of interest"
glimpse(lodesworkers_blkgp)
## Rows: 43
## Columns: 16
## $ blkgroup <dbl> 510010901001, 510010901002, 510010…
## $ medc_allworkersblkgr <dbl> 14.653191, 14.067786, 14.683464, 1…
## $ medc_livewithin40blkgr <dbl> 5.720533, 4.908061, 6.427316, 6.26…
## $ medc_25_resblkgr <dbl> 6.612876, 4.908061, 6.427316, 6.95…
## $ workersInblkgr <int> 452, 192, 147, 122, 128, 399, 1447…
## $ liveoutsideRegionblkgr <int> 33, 18, 9, 11, 53, 131, 425, 4, 2,…
## $ liveinsideRegionblkgr <int> 419, 174, 138, 111, 75, 268, 1022,…
## $ perc_workers_liveinRegionblkgr <dbl> 92.69912, 90.62500, 93.87755, 90.9…
## $ perc_workers_liveoutsideRegionblkgr <dbl> 7.300885, 9.375000, 6.122449, 9.01…
## $ workersw40blkgr <int> 411, 173, 138, 110, 75, 269, 1030,…
## $ workers25blkgr <int> 417, 173, 138, 111, 75, 268, 1020,…
## $ avgc_allworkersblkgr <dbl> 15.101568, 16.681547, 14.584871, 1…
## $ avgc_livewithin40blkgr <dbl> 5.785433, 5.014835, 6.337034, 5.95…
## $ avgc_25_resblkgr <dbl> 6.524076, 5.240530, 6.337034, 6.27…
## $ county <int> 51001, 51001, 51001, 51001, 51001,…
## $ GEOID <chr> "510010901001", "510010901002", "5…
metaworkers %>%
filter(su_blkgp == 1) %>%
select(varname, about) %>% as.list()
## $varname
## [1] "blkgroup" "medc_allworkersblkgr"
## [3] "medc_livewithin40blkgr" "medc_25_resblkgr"
## [5] "workersInblkgr" "liveoutsideRegionblkgr"
## [7] "liveinsideRegionblkgr" "perc_workers_liveinRegionblkgr"
## [9] "perc_workers_liveoutsideRegionblkgr" "workersw40blkgr"
## [11] "workers25blkgr" "avgc_allworkersblkgr"
## [13] "avgc_livewithin40blkgr" "avgc_25_resblkgr"
## [15] "county"
##
## $about
## [1] "12-digit census block group code where the workers are employed (workplace census block group)"
## [2] "Median \"as the crow flies\" commuting distance for all workers employed in the census block group"
## [3] "Median \"as the crow flies\" commuting distance for workers employed in the census block group who live within 40 miles of work"
## [4] "Median \"as the crow flies\" commute for workers employed in the census block group who live in census tract where at least 25 region of interest workers live"
## [5] "The total number of workers employed in the census block group"
## [6] "The number of workers employed in the census block group that live outside the region of interest"
## [7] "The number of workers employed in the census block group who live outside the region of interest"
## [8] "The percent of workers employed in the census block group who live inside the region of interest"
## [9] "The percent of workers employed in the census block group who live outside the region of interest"
## [10] "The number of workers employed in the census block group who live within 40 miles of work"
## [11] "The number of workers employed in the census block group who live in a census tract where at least 25 region of interest workers live"
## [12] "Average \"as the crow flies\" commuting distance for all workers employed in the census block group"
## [13] "Average \"as the crow flies\" commuting distance for workers employed in the census block group who live within 40 miles of work"
## [14] "Average \"as the crow flies\" commute for workers employed in the census block group who live in census tract where at least 25 region of interest workers live"
## [15] "5-digit county code"
lodesresidents_blkgp %>% select(avgc_allblk, avgc_within40blk, avgc_25_employeesblk, avgc_workinRegionblk, medc_allblk, medc_within40blk, medc_25_employeesblk, medc_workinRegionblk) %>%
select(where(~is.numeric(.x))) %>%
as.data.frame() %>%
stargazer(., type = "text", title = "Summary Statistics", digits = 1,
summary.stat = c("mean", "sd", "min", "median", "max"))
##
## Summary Statistics
## ====================================================
## Statistic Mean St. Dev. Min Median Max
## ----------------------------------------------------
## avgc_allblk 44.4 13.7 29.6 42.7 106.1
## avgc_within40blk 10.1 3.4 6.8 9.4 22.3
## avgc_25_employeesblk 18.6 10.9 9.6 16.5 67.0
## avgc_workinRegionblk 8.3 3.2 5.1 7.6 20.2
## medc_allblk 41.9 14.3 24.7 38.7 104.3
## medc_within40blk 10.0 3.9 5.5 9.1 24.0
## medc_25_employeesblk 16.0 11.1 7.9 13.6 63.3
## medc_workinRegionblk 8.3 3.7 4.6 7.4 24.0
## ----------------------------------------------------
lodesworkers_blkgp %>% select(avgc_allworkersblkgr, avgc_livewithin40blkgr, avgc_25_resblkgr, medc_allworkersblkgr, medc_livewithin40blkgr, medc_25_resblkgr, perc_workers_liveoutsideRegionblkgr) %>%
select(where(~is.numeric(.x))) %>%
as.data.frame() %>%
stargazer(., type = "text", title = "Summary Statistics", digits = 1,
summary.stat = c("mean", "sd", "min", "median", "max"))
##
## Summary Statistics
## =================================================================
## Statistic Mean St. Dev. Min Median Max
## -----------------------------------------------------------------
## avgc_allworkersblkgr 27.1 10.9 9.0 24.1 51.4
## avgc_livewithin40blkgr 8.9 2.8 5.0 8.9 24.6
## avgc_25_resblkgr 7.9 2.6 5.2 7.3 22.4
## medc_allworkersblkgr 26.6 12.8 6.9 24.8 59.3
## medc_livewithin40blkgr 9.0 2.9 4.9 8.8 24.1
## medc_25_resblkgr 8.1 2.8 4.9 7.6 22.2
## perc_workers_liveoutsideRegionblkgr 21.7 10.2 0.0 21.5 41.4
## -----------------------------------------------------------------
longr <- lodesresidents_tract %>% select(c(tract, avgc_alltr, avgc_within40tr, avgc_25_employeestr, avgc_workinRegiontr, medc_alltr, medc_within40tr, medc_25_employeestr, medc_workinRegiontr)) %>%
pivot_longer(-tract, names_to = "measure", values_to = "value")
longr$measure <- factor(longr$measure,
levels = c("avgc_alltr", "medc_alltr", "avgc_within40tr", "medc_within40tr", "avgc_25_employeestr", "medc_25_employeestr", "avgc_workinRegiontr",
"medc_workinRegiontr"))
longr %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longr <- lodesresidents_blkgp %>% select(c(blkgroup, avgc_allblk, avgc_within40blk, avgc_25_employeesblk, avgc_workinRegionblk, medc_allblk, medc_within40blk, medc_25_employeesblk, medc_workinRegionblk)) %>%
pivot_longer(-blkgroup, names_to = "measure", values_to = "value")
longr$measure <- factor(longr$measure,
levels = c("avgc_allblk", "medc_allblk", "avgc_within40blk", "medc_within40blk", "avgc_25_employeesblk", "medc_25_employeesblk", "avgc_workinRegionblk",
"medc_workinRegionblk"))
longr %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longr <- lodesresidents_block %>% select(c(h_geocode, avgc_all, avgc_within40, avgc_25_employees, avgc_workinRegion, medc_all, medc_within40, medc_25_employees, medc_workinRegion)) %>%
pivot_longer(-h_geocode, names_to = "measure", values_to = "value")
longr$measure <- factor(longr$measure,
levels = c("avgc_all", "medc_all", "avgc_within40", "medc_within40", "avgc_25_employees", "medc_25_employees", "avgc_workinRegion",
"medc_workinRegion"))
longr %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longw <- lodesworkers_tract %>% select(c(tract, avgc_allworkerstr, avgc_livewithin40tr, avgc_25_restr, medc_allworkerstr, medc_livewithin40tr, medc_25_restr)) %>%
pivot_longer(-tract, names_to = "measure", values_to = "value")
longw$measure <- factor(longw$measure,
levels = c("avgc_allworkerstr", "medc_allworkerstr", "avgc_livewithin40tr", "medc_livewithin40tr", "avgc_25_restr", "medc_25_restr"))
longw %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longw <- lodesworkers_blkgp %>% select(c(blkgroup, avgc_allworkersblkgr, avgc_livewithin40blkgr, avgc_25_resblkgr, medc_allworkersblkgr, medc_livewithin40blkgr, medc_25_resblkgr)) %>%
pivot_longer(-blkgroup, names_to = "measure", values_to = "value")
longw$measure <- factor(longw$measure,
levels = c("avgc_allworkersblkgr", "medc_allworkersblkgr", "avgc_livewithin40blkgr", "medc_livewithin40blkgr", "avgc_25_resblkgr", "medc_25_resblkgr"))
longw %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
longw <- lodesworkers_block %>% select(c(w_geocode, avgc_allworkers, avgc_livewithin40, avgc_25_res, medc_allworkers, medc_livewithin40, medc_25_res)) %>%
pivot_longer(-w_geocode, names_to = "measure", values_to = "value")
longw$measure <- factor(longw$measure,
levels = c("avgc_allworkers", "medc_allworkers", "avgc_livewithin40", "medc_livewithin40", "avgc_25_res", "medc_25_res"))
longw %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
geom_histogram() +
facet_wrap(~measure, scales = "free", ncol = 2)
Average commute distance.
pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$avgc_alltr)
leaflet(lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_tract,
fillColor = ~pal(avgc_alltr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(lodes_tract$avgc_alltr, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_tract$avgc_alltr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$avgc_allblk)
leaflet(lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_blkgp,
fillColor = ~pal(avgc_allblk),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(lodes_blkgp$avgc_allblk, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_allblk,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
Average commmute distance.
pal <- colorNumeric("plasma", reverse = T, domain =
lodes_tract$avgc_allworkertr)
leaflet(lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_tract,
fillColor = ~pal(avgc_allworkerstr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(lodes_tract$avgc_allworkerstr, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_tract$avgc_allworkerstr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain =
lodes_blkgp$avgc_allworkersblkgr)
leaflet(lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_blkgp,
fillColor = ~pal(avgc_allworkersblkgr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(lodes_blkgp$avgc_allworkersblkgr, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_allworkersblkgr,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
Average commute among those who work with in 40 miles of home.
pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$avgc_within40tr)
leaflet(lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_tract,
fillColor = ~pal(avgc_within40tr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(lodes_tract$avgc_within40tr, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_tract$avgc_within40tr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$avgc_within40blk)
leaflet(lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_blkgp,
fillColor = ~pal(avgc_within40blk),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(lodes_blkgp$avgc_within40blk, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_within40blk,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$avgc_livewithin40tr)
leaflet(lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_tract,
fillColor = ~pal(avgc_livewithin40tr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(lodes_tract$avgc_livewithin40tr, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_tract$avgc_livewithin40tr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$avgc_livewithin40blkgr)
leaflet(lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_blkgp,
fillColor = ~pal(avgc_livewithin40blkgr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(lodes_blkgp$avgc_livewithin40blkgr, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_livewithin40blkgr,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
Average commute distances for people who work and live in the Eastern Shore region.
pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$avgc_workinRegiontr)
leaflet(lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_tract,
fillColor = ~pal(avgc_workinRegiontr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
"Average commute (mi): ", round(lodes_tract$avgc_workinRegiontr, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_tract$avgc_workinRegiontr,
title = "Average commute (mi)", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$avgc_workinRegionblk)
leaflet(lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_blkgp,
fillColor = ~pal(avgc_workinRegionblk),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
"Average commute (mi): ", round(lodes_blkgp$avgc_workinRegionblk, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_workinRegionblk,
title = "Average commute (mi)", opacity = 0.7)
Block level maps are slow to render and may be added later.
pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$perc_workers_liveoutsideRegiontr)
leaflet(lodes_tract) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_tract,
fillColor = ~pal(perc_workers_liveoutsideRegiontr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
"Percent of workers: ", round(lodes_tract$perc_workers_liveoutsideRegiontr, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_tract$perc_workers_liveoutsideRegiontr,
title = "Percent of workers <br> who live outside <br> Eastern Shore region", opacity = 0.7)
pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$perc_workers_liveoutsideRegionblkgr)
leaflet(lodes_blkgp) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = lodes_blkgp,
fillColor = ~pal(perc_workers_liveoutsideRegionblkgr),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
"Percent of workers: ", round(lodes_blkgp$perc_workers_liveoutsideRegionblkgr, 2))) %>%
addLegend("bottomright", pal = pal, values = lodes_blkgp$perc_workers_liveoutsideRegionblkgr,
title = "Percent of workers <br> who live outside <br> Eastern Shore region", opacity = 0.7)
Block level maps are slow to render and may be added later.